﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using service;

namespace Trathat
{
    public partial class Nhomsanpham : System.Web.UI.Page
    {
        LoaisanphamService loaisanphamService = new LoaisanphamService();
        SanphamTrathatService sanphamService = new SanphamTrathatService();
        protected void Page_Load(object sender, EventArgs e)
        {
            string s = Request.QueryString["Nhom"];
            getListLoaisanphamByNhom(Convert.ToInt64(s));
            if (s == "1")
                lblNhom.Text = " > Trà cụ";
            else
                lblNhom.Text = " > Trà";
        }

        private void getListLoaisanphamByNhom(long id)
        {
            listLoaisanpham.DataSource = loaisanphamService.getListLoaiSanphamByNhom(id);
            listLoaisanpham.DataBind();
        }
        protected void listNhomsanpham_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            DataList a = (DataList)e.Item.FindControl("listsanpham");
            BindGrid(a, listLoaisanpham.DataKeys[e.Item.ItemIndex].ToString());
        }

        private void BindGrid(DataList a, string p)
        {
            a.DataSource = sanphamService.getListTop8SanphamByLoai(Convert.ToInt64(p));
            a.DataBind();

        }

        protected void lnkNhom_Click(object sender, EventArgs e)
        {

        }
    }
}